package com.cq.androidtools.jetpack.startup

import android.content.Context
import android.util.Log
import androidx.startup.Initializer
import androidx.work.Configuration
import androidx.work.WorkManager

/**
 * 作者: CQ
 * 日期: 2021-05-31
 * 说明: 初始化 WorkManager 的 Initializer
 */
class WorkManagerInitializer : Initializer<WorkManager> {
    override fun create(context: Context): WorkManager {
        val configuration = Configuration.Builder()
            .setMinimumLoggingLevel(Log.DEBUG)
            .build()
        WorkManager.initialize(context, configuration)
        return WorkManager.getInstance(context)
    }

    // 此组件无需任何依赖
    override fun dependencies() = emptyList<Class<out Initializer<*>>>()
}